<?php

/**
* <class description>
* 
* @author
* @link
*/

class _Suppliers extends Controller
{
    public function __construct()
    {
        parent::Controller();   
        $this->load->model('productsmodel');  
        $this->load->library("form_validation");    
        $this->_process_form();     
    }    

    public function supplier_products($id=false)
    {

        $data["supplier"] = $id;
        $data["products"] = $this->productsmodel->admin_get_supplier_products($id);  
                                                               
                                                                           
        if($this->input->post("edit_supplier_products") !== false){
 
            $this->load->view("supplier_products_edit", $data);

        } else {

            $this->load->view("supplier_products_view", $data); 

        }

    }

    function _process_form()
    {
                                     
        if($this->input->post("suppliers_module_submit_action") !== FALSE){

            foreach($this->input->post("products") as $prod_input){

                $data["Code_Products"] = $prod_input["code"];  
                $data["Price_Products"] = $prod_input["price"];
                $data["Currency_Products"] = $prod_input["currency"];
                $id = $prod_input["product_id"];

                $this->productsmodel->update_product($id, $data);

            }

        }

    }


}

/* End of file users.php */
/* Location: ./system/application/modules/frontoffice/controllers/home.php  */ 